<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>数组中的第k个最大元素</title>
</head>
<body>
  <script>
    function fn(nums, k) {
      nums.sort((a, b) => a-b);
      nums.reverse();
      return nums[k - 1];
    }
    console.log(fn([3,2,1,5,6,4], 2))
  </script>
</body>
</html>